package ute.mvc.dao;

import javax.servlet.ServletContext;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import ute.mvc.model.MyFile;

@Repository ("fileDAO")
public class FileDAOImpl implements FileDAO{
	@Autowired
	SessionFactory sessionFactory;

	
	public MyFile getFileByFileId(int fileId) {
		return (MyFile) sessionFactory.getCurrentSession().get(MyFile.class, fileId);
	}

	public void addFile(MyFile file) {
		sessionFactory.getCurrentSession().save(file);
	}

	public void updateFile(MyFile file) {
		sessionFactory.getCurrentSession().merge(file);
	}

	public void deleteFile(MyFile file) {
		sessionFactory.getCurrentSession().delete(file);
	}

}
